package view.bullet
{
	import flash.display.MovieClip;
	import flash.geom.Point;
	
	import ui.ria.Lightning;
	
	import utils.GameUtils;
	import utils.HitTest;
	
	import view.Arm.BaseTank;

	/**
	 *
	 *@author CrazyChen 
	 *2013-4-14
	 */	
	public class DBullet extends BaseBullet
	{
		/**
		 *发射对象 
		 */
		public var sendTarget:BaseTank;
		
		private var time:int;
		
		public function DBullet()
		{
			super();
			display = new Lightning();
			this.addChild(display);
			display.y = -40;
		}
		
		override public function move():void{
			if(sendTarget.shoutTarget){
				this.height =  GameUtils.getTwoPointDistance(new Point(sendTarget.shoutTarget.x,sendTarget.shoutTarget.y),new Point(sendTarget.x,sendTarget.y));
				this.rotation = GameUtils.getRotation(new Point(sendTarget.x,sendTarget.y),new Point(sendTarget.shoutTarget.x,sendTarget.shoutTarget.y));
			}else{
				remove();
			}
		}
		
		override public function checkHitMonster():void{
			var i:int = 0;
			var lens:int = monterAry.length;
			for(i;i<lens;i++){
				if(HitTest.complexHitTestObject(monterAry[i],this)){
					time++;
					if(time%24 == 0){
						time = 0;
						monterAry[i].blood -= ART;
					}	
					return;
				}
			}
			i=0;
			lens = plantAry.length;
			for(i;i<lens;i++){
				if(HitTest.complexHitTestObject(plantAry[i],this)){
					time++;
					if(time%24 == 0){
						time = 0;
						plantAry[i].blood -= ART;
					}	
					return;
				}
			}
		}
	}
}